<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <a href="/home">测试</a>
  <script>
    //获取元素
    let a = document.querySelector('a');
    //绑定事件
    a.onclick = function(e){
      console.log('run run run');
      //阻止 a 元素的默认行为
      e.preventDefault();
      //调用 history.pushState 
      history.pushState({id: 200}, '', '/home');
    }

    //绑定全局事件
    window.onpopstate = function(){
      console.log('进行了前进与后退')
    }

  </script>
</body>
</html>